<?php
/**
 * @author shuang
 * @date 2016-10-24 16:41:53
 */
$this->registerCssFile("/css/validate.css");
$this->registerCssFile("/js/ui-dialog.css");
$this->registerCssFile("/js/plugins/fileinput/css/fileinput.css");
$this->registerJsFile("/js/plugins/fileinput/fileinput.js", [\yii\web\JqueryAsset::className(), "depends" => "\yii\web\JqueryAsset"]);
$this->registerJsFile("/js/plugins/fileinput/fileinput_locale_zh.js", [\yii\web\JqueryAsset::className(), "depends" => "\yii\web\JqueryAsset"]);
$this->registerJsFile("/js/jquery.form.min.js", [\yii\web\JqueryAsset::className(), "depends" => "\yii\web\JqueryAsset"]);
$this->registerJsFile("/js/Validform_v5.3.2_min.js", [\yii\web\JqueryAsset::className(), "depends" => "\yii\web\JqueryAsset"]);
$this->registerJsFile("/js/WdatePicker.js", [\yii\web\JqueryAsset::className(), "depends" => "\yii\web\JqueryAsset"]);
$this->registerJsFile("/js/dialog-plus-min.js", [\yii\web\JqueryAsset::className(), "depends" => "\yii\web\JqueryAsset"]);
$this->registerJsFile("/js/common.js", [\yii\web\JqueryAsset::className(), "depends" => "\yii\web\JqueryAsset"]);
$this->registerJsFile('/js/task.js', [\yii\web\JqueryAsset::className(), "depends" => "\yii\web\JqueryAsset"]);

use \yii\helpers\Url;
use common\components\MTools;
use yii\helpers\Html;
use frontend\models\WB_TaskArea;

$singleData = MTools::dictDropdownDesc("task_single_num");
$sampleData = MTools::dictDropdownDesc("task_sample_num", true, "--请选择--   如选择2张,请拼图上传样图！");
$this->registerJs('task.init({gradeid:"' . Yii::$app->user->identity->userprofile->gradeid . '",areaType:' . $areaType . ',areaSelected:"' . $model->type . '",speedtype:"' . $model->is_speed . '",mobiletype:"' . $model->is_offer_mobile . '",priceSelected:"' . $model->task_price_id . '"});AjaxInitForm("#addForm", "#btnSubmit", 1);');
$this->registerJs('task.upImgbind({updiv:$(\'#pickfiles\'),url:"",divimg:$(\'#divimg\'),imgfile:$(\'#imgfile\')});');
echo $this->render("//layouts/breadcrumb", ["url" => Url::toRoute(["task/add"]), "title" => "发布任务"]);
?>
<div class="container-fluid">
    <div class="row-fluid">
        <div class="span12 well ibox float-e-margins">
            <div class="ibox-title">发布任务</div>
            <div class="well-content ibox-content">
                <form name="addForm" method="post" action="<?php echo Url::toRoute(["add"]) ?>" id="addForm" class="form-horizontal form-bordered" url="<?php echo Url::toRoute(["add"]) ?>">
                    <?php echo MTools::getTemplate("task-send.html"); ?>
                    <div class="control-group">
                        <label class="control-label">任务名称</label>
                        <div class="controls">
                            <input class="span6" id="name" name="title" type="text" placeholder="如需拼图请在标题或简介中写明如何拼图" datatype="*6-20" errormsg="长度在6-20位之间" nullmsg="请输入任务标题" sucmsg=" "  value="<?php echo $model->title; ?>"/>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">任务类型</label>
                        <div class="controls">
                            <ul class="wizard nav nav-task-type">
                                <?php foreach (MTools::dictDropdown("task_type") as $item): ?>
                                    <li class="">
                                        <a href="#<?php echo $item["id"]; ?>" data-toggle="tab" data-id="<?php echo $item["id"]; ?>"><?php echo $item["name"]; ?></a>
                                    </li>
                                <?php endforeach; ?>
                            </ul>
                            <input type="hidden" name="type" />
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">任务单价</label>
                        <div class="controls">
                            <ul class="wizard nav nav-task-price" id="danjia"></ul>
                            <input type="hidden" name="task_price_id" />
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">数量</label>
                        <div class="controls">
                            <div style="display: inline-block;" class="span3">
                                <input name="number" placeholder="单次任务20单起" value="<?php echo $model->number; ?>" id="num" type="text" datatype="n" nullmsg="请输入数量" errormsg="必须为数字" sucmsg=" " ajaxurl="<?php echo Url::toRoute(["ajaxchecknumber"]) ?>" class="span12"/>
                            </div>
                            <span style="padding:0 5px;">单人可接</span>
                            <select name="single_meet" id="GetNO" class="form-control mb15 span3 " >
                                <?php foreach ($singleData as $item): ?>
                                    <option value="<?php echo $item["id"]; ?>" <?php echo $item["id"] == $model->single_meet ? "selected" : null; ?>><?php echo $item["name"]; ?></option>
                                <?php endforeach; ?>
                            </select>
                        </div>
                    </div>
                    <div class="control-group ">
                        <label class="control-label">所需截图</label>
                        <div class="controls">
                            <select name="sample_figure_count" class="form-control mb15 span3">
                                <?php foreach ($sampleData as $item): ?>
                                    <option value="<?php echo $item["id"]; ?>" <?php echo $item["id"] == $model->sample_figure_count ? "selected" : null; ?>><?php echo $item["name"]; ?></option>
                                <?php endforeach; ?>
                            </select>
                        </div>
                    </div>
                    <div class="control-group" id="xuanshou">
                        <label class="control-label">选手</label>
                        <div class="controls">
                            <input class="span3" name="publicode" type="text"  id="gzh"  value="<?php echo $model->publicode; ?>" placeholder="" />                       
                        </div>
                    </div>
                    <div class="control-group" id="selectquyu" style="display: none">
                        <label class="control-label">限定区域</label>
                        <div class="controls">
                            <select id="province" name="areaname" class="form-control mb15 span3"  sucmsg=" " ajaxurl="<?php echo Url::toRoute(["ajaxcheckarea"]) ?>" >
                                <?php foreach (WB_TaskArea::getdropdownArea() as $item): ?>
                                    <option value="<?php echo $item; ?>"><?php echo $item; ?></option>
                                <?php endforeach; ?>
                            </select>
                            <div id="perNO"></div>
                        </div>
                    </div>
                    <div class="control-group" id="tasklink">
                        <label  class="control-label">任务</label>
                        <div class="controls">
                            <input class="span6"  type="text" id="tpurl" name="vote_address" placeholder="" value="<?php echo $model->vote_address; ?>" nullmsg="请输入投票地址" sucmsg=" " />
                        </div>
                    </div>
<!--                    <div class="control-group">
                        <label class="control-label">简介</label>
                        <div class="controls">
                            <textarea class="span6" id="jianjie" name="note" rows="7" placeholder="公众号或链接地址可以写到上面，方便会员复制，提高任务效率，请在这里写清楚任务流程和截图标准！投票内容描述越清晰，做的速度越快！" ><?php echo $model->note; ?></textarea>
                        </div>
                    </div>-->
                    <div class="control-group pingjianeirong " style="display: none">
                        <label class=" control-label">评价内容</label>
                        <div class="controls">
                            <textarea class="span6" id="pinjia" name="evaluation" rows="7" placeholder="此处填写提供给投手的评价内容，为保证评论不重复多少票数请提供多少条评论,每个评论用 | 分割！" ><?php echo $model->evaluation; ?></textarea>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">发布时间</label>
                        <div class="controls">
                            <div style="display: inline-block;" class="span3">
                                <input class="span12" type="text" id="fatime" name="ordersenddate" value="<?php echo Yii::$app->formatter->asDatetime($model->ordersenddate); ?>" placeholder="预约未来48小时内发布" onfocus="WdatePicker({dateFmt: 'yyyy-MM-dd HH:mm:ss'})" errormsg="请选择正确的日期" datatype="/^\s*$|^\d{4}\-\d{1,2}\-\d{1,2}\s{1}(\d{1,2}:){2}\d{1,2}$/" nullmsg="" sucmsg=" " />
                                如不需要预约此项可不填写
                            </div>
                            <span style="padding:0 5px;">截止日期(选填)</span>
                            <input class="span3" type="text" id="endtime" name="end_at" value="<?php echo Yii::$app->formatter->asDatetime($model->end_at); ?>" placeholder="预约未来48小时内发布" onfocus="WdatePicker({dateFmt: 'yyyy-MM-dd HH:mm:ss'})" errormsg="请选择正确的日期" datatype="/^\s*$|^\d{4}\-\d{1,2}\-\d{1,2}\s{1}(\d{1,2}:){2}\d{1,2}$/" nullmsg="" sucmsg=" "  />
                        </div>
                    </div>
                    <div class="control-group" id="tszh"  style="display: none">
                        <label class="control-label redcolor">投手提供注册/手机账号</label>
                        <div class="controls switch grey span2">
                            <input id="toushouzh_1" class="orange" name="is_offer_mobile" value="1" checked="<?php $model->is_offer_mobile === 0 ? "checked" : null; ?>"  type="radio">	
                            <label for="toushouzh_1" onclick="">是</label>
                            <input id="toushouzh_0" class="orange" name="is_offer_mobile" value="0" checked="<?php $model->is_offer_mobile === 0 ? "checked" : null; ?>" type="radio">
                            <label for="toushouzh_0" onclick="">否</label>
                            <span class="slide-button lightblue"></span>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">限速</label>
                        <div class="controls switch grey span2">
                            <input id="xiansu_1" class="blue" name="is_speed" value="1" checked="<?php $model->is_speed === 0 ? "checked" : null; ?>"  type="radio">	
                            <label for="xiansu_1" onclick="">是</label>
                            <input id="xiansu_0" class="blue" name="is_speed" value="0" checked="<?php $model->is_speed === 0 ? "checked" : null; ?>" type="radio">
                            <label for="xiansu_0" onclick="">否</label>
                            <span class="slide-button lightblue"></span>
                        </div>
                    </div>
                    <div class="control-group" id="sudu">
                        <label  class="control-label">设置限速</label>
                        <div class="controls">
                            <input class="span3"  type="text" name="speed_limit" value="<?php echo $model->speed_limit; ?>"  id="xzNO" datatype="n" nullmsg="请输入五分钟内可投的票数数量" errormsg="必须为数字" sucmsg=" "  />
                            输入五分钟内限制的票数，如果五分钟内限制票数没有投完，将累计到下一计时点。
                        </div>
                    </div>

                    <!--                    <div class="control-group">
                                            <label class="control-label">样图数量</label>
                                            <div class="controls">
                                                <input name="sample_figure_count" value="<?php //echo $model->sample_figure_count;                  ?>" id="sample_figure_count" class="span3" type="text" datatype="n" nullmsg="请输入数量" errormsg="必须为数字" sucmsg=" "/>                       
                                            </div>
                                        </div>-->
                    <div class="control-group">
                        <label class="control-label">样图</label>
                        <div class="controls">
                            请确保样图清晰准确，将直接影响到做任务的效率和质量<br/>
                            <input id="qrpickfiles" name="WB_Task[sample_figure]" type="file" multiple class="btn btn-success">
                            <?php if ($model->sample_figure): ?>
                                <div class="col-sm-6">
                                    <?php echo Html::tag('img', '', ['src' => MTools::Qiniu480($model->sample_figure), 'class' => 'img-thumbnail']); ?>
                                    <?php echo Html::hiddenInput("sample_figure", $model->sample_figure); ?>
                                </div>
                            <?php endif; ?>
                        </div>
                    </div>
<!--                    <div class="control-group">
                        <label class=" control-label">二维码</label>
                        <div class="controls">
                            如不需要扫码，请不要上传，如需修改二维码，在任务列表点功能按钮修改<br/>
                            <input id="qrpickfilesqrcode" name="WB_Task[qrcode]" type="file" multiple class="btn btn-success">
                            <?php if ($model->qrcode): ?>
                                <div class="col-sm-6">
                                    <?php //echo Html::tag('img', '', ['src' => MTools::Qiniu480($model->qrcode), 'class' => 'img-thumbnail']); ?>
                                    <?php //echo Html::hiddenInput("qrcode", $model->qrcode); ?>
                                </div>
                            <?php endif; ?>
                        </div>
                    </div>-->
<!--                    <div class="control-group">
                        <label  class="control-label">备注</label>
                        <div class="controls">
                            <textarea class="span6" id="beizhu" name="description" rows="7" placeholder="仅发布者可见，便于做记录。" ><?php echo $model->description; ?></textarea>
                        </div>
                    </div>-->
<!--                    <div class="control-group">
                        <label  class="control-label">注意事项</label>
                        <div class="controls">
                            <textarea class="span6" id="beizhu" name="considerations" rows="7" placeholder="注意事项" ><?php echo $model->considerations; ?></textarea>
                        </div>
                    </div>-->
                    <div class="control-group clonediv" style="display: none;">
                        <label  class="control-label">任务步骤</label>
                        <div class="controls">
                            <textarea class="span6" name="step[]" rows="7" placeholder="" ></textarea>
                            <div class="mb15"></div>
                            <input name="stepfile[]" type="file" multiple class="btn btn-success">
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">&nbsp;&nbsp;</label>
                        <input type="hidden" name="stepcount" value="0" />
                        <div class="controls">
                        <a class="btn addstep">添加步骤</a>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label"></label>
                        <div class="controls">
                            <input name="btnSubmit" id="btnSubmit" type="submit" class=" btn lightblue span2" value="提  交" />
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>